import type { Address } from '@/types/address'
import { http } from '@/utils/http'

/**
 * 获取会员地址列表
 * @returns
 */
export const getMemberAddress = () => {
  return http<Address[]>({
    method: 'GET',
    url: '/member/address',
  })
}

/**
 * 添加会员地址
 * @param data
 * @returns
 */
export const postMemberAddress = (data: Address) => {
  return http<Address>({
    method: 'POST',
    url: '/member/address',
    data,
  })
}

/**
 * 根据id获取地址信息
 * @param id
 * @returns
 */
export const getMemberAddressbyId = (id: string) => {
  return http<Address>({
    method: 'GET',
    url: `/member/address/${id}`,
  })
}

/**
 * 修改会员地址信息
 * @param id
 * @param data
 * @returns
 */
export const putMemberAddressbyId = (id: string, data: Address) => {
  return http({
    method: 'PUT',
    url: `/member/address/${id}`,
    data,
  })
}

export const deleteMemberAddressbyId = (id: string) => {
  return http({
    method: 'DELETE',
    url: `/member/address/${id}`,
  })
}
